package com.dc.ftp.broadcast;


import android.bluetooth.BluetoothAdapter;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
import com.dc.ftp.utils.MyLog;

public class BluetoothBroadcast  extends BroadcastReceiver{
    public static boolean BluetoothAviable = true;
    @Override
    public void onReceive(Context context, Intent intent) {
        MyLog.e("蓝牙", "蓝牙状态改变");
       String state=BluetoothAdapter.EXTRA_STATE;
        int bluestate = intent.getIntExtra(state, -1);//读取蓝牙状态
        String msg="";
        // 蓝牙开闭状态接收器

        //打开中，已打开，关闭中，已关闭
        switch (bluestate) {
            case BluetoothAdapter.STATE_TURNING_ON:
                msg="蓝牙打开中";
                break;
            case BluetoothAdapter.STATE_ON:
                msg="蓝牙已打开";
                break;
            case BluetoothAdapter.STATE_TURNING_OFF:
                msg="蓝牙关闭中";
                break;
            case BluetoothAdapter.STATE_OFF:
                msg="蓝牙已关闭";
                break;
        }
        Toast.makeText(context,msg,Toast.LENGTH_LONG).show();
    }

}
